QUESTION
Evaluate the post fixed expression⢠Initialize an empty stack.While there are more symbols in the postfix string{ If the token is an operand, push it onto the stack. If the token is an operator{o Pop the two topmost values from the stack, and store them in the order t1, the topmost, and t2 the second value.o Calculate the partial result in the following order t2 operator t1o Push the result of this calculation onto the stack.NOTE: If the stack does not have two operands, a malformed postfix expression has occurred, and evaluation should be terminated.}}⢠When the end of the input string is encountered, the result of the expression is popped from the stack.NOTE: If the stack is empty or if it has more than one operand remaining, the result is unreliable.Extend this algorithm to include square brackets and curly braces. For example, expressions of the following kind should be considered:⢠2 + { 2 * ( 10 â 4 ) / [ { 4 * 2 / ( 3 + 4) } + 2 ] â 9 }⢠2 + } 2 * ( 10 â 4 ) / [ { 4 * 2 / ( 3 + 4) } + 2 ] â 9 {Implement the above two algorithms for the following binary operators: addition +, subtraction -, multiplication *, division /, and modulus operation %. All operations are integer operations. To keep things simple, place at least one blank space between each token in the input string.
ANSWER:
Place an order in 3 easy steps. Takes less than 5 mins.